package com.xxd.spring.boot.demo.wubolin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxd.spring.boot.demo.wubolin.entity.Student;
import com.xxd.spring.boot.demo.wubolin.exception.MyException;
import com.xxd.spring.boot.demo.wubolin.mapper.StudentMapper;
import com.xxd.spring.boot.demo.wubolin.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Student stuFraction(String num) throws MyException {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("num",num);
        Student list = studentMapper.selectOne(queryWrapper);
        if (list == null){
            throw new MyException("学生不存在","123");
        }
        return studentMapper.stuFraction(num);
    }

    @Override
    public List<Student> all() {
        return studentMapper.all();
    }


}
